import {
	getcurrentSift,
	gethighProduct,
	getdominatorProduct,
	getcurrentDetail,
	getminuteProduct,
	getcurrentTime,
	getearningsProduct,
	getholdsProduct,
	getregularSift,
	getregularSiftWinnow,
	getregularDetail,
	getregularMinuteProduct,
	getregularHoldsProduct,
	getAllProduct,
	getUserGoldProductList,
	sellCurrent,
	sendCode,

} from "../../http/licai/licaihttp.js"

export default ({
	namespaced: true,
	state: {
		currentSift: [],
		highProduct: {},
		dominatorProduct: [],
		currentDetails: [],
		listData: ['1', '2', '1', '2', '1'],
		time: ['1', '2', '3', '4', '5'],
		earningsProducts: {},
		holdsProduct:[],
		regularSifts:[],
		regularSiftWinnow:[],
		regularDetail:[],
		regularMinuteProduct:[],
		funds:[],
		golds:[],
		regular:[],
		sifts:[],
	},
	mutations: {
		currentSift(state, a) {
			// console.log(a,'data');
			state.currentSift = a
		},
		highProduct(state, a) {
			state.highProduct = a
		},
		dominatorProduct(state, a) {
			console.log(a,'data');
			state.dominatorProduct = a
		},
		currentDetails(state, a) {
			console.log(a,'list4444444');
			state.currentDetails = a
		},
		listData(state, a) {
			state.listData = a
		},
		time(state, a) {
			state.time = a
		},
		earningsProductAll(state, a) {
			// console.log(a,'asd')
			state.earningsProducts = a
			// console.log(state.earningsProducts,'earningsProducts')
		},
		holdsProduct(state, a){
			console.log(a,'活期');
			state.holdsProduct = a
		},
		regularSift(state,a){
			state.regularSifts =a
		},
		regularSiftWinnow(state,a){
			state.regularSiftWinnow = a
		},
		regularDetail(state,a){
			console.log(a,'定期详细');
			state.regularDetail = a
		},
		regularMinuteProduct(state,a){
			state.regularMinuteProduct = a
		},
		AllProduct(state,a){
			state.AllProduct =a 
		},
		funds(state,a){
			state.funds =a
		},
		golds(state,a){
			state.golds =a
		},
		regular(state,a){
			state.regular =a
		},
		sifts(state,a){
			state.sifts =a
		}
	},
	actions: {
		async getcurrentSifts(context) {

			const data = await getcurrentSift()
			console.log(data)
			context.commit('currentSift', data.data)
		},
		async gethighProducts(context) {
			const data = await gethighProduct()

			context.commit('highProduct', data.data)
		},
		//查询活期理财产品展示
		async getdominatorProducts(context, a) {

			const data = await getdominatorProduct()

			context.commit('dominatorProduct', data.data)
		},
		//查询理财产品详情展示
		async getcurrentDetails(context, a) {

			const data = await getcurrentDetail(a)

			context.commit('currentDetails', data.data)
		},
		//查询理财产品详情折线图 
		async getminuteProducts(context, a) {

			const data = await getminuteProduct(a)


			context.commit('listData', data.data)
		},
		//折线图一个月时间
		async getcurrentTimes(context, a) {
			const data = await getcurrentTime(a)
			console.log(data,123)
			context.commit('time', data.data)
		},
		//查询活期理财产品全部收益
		async getearningsProducts(context, a) {
			const data = await getearningsProduct()
			console.log(data,'aaaa')
			context.commit('earningsProductAll', data.data)
		},
		
		//定期产品精选优品展示
		async getregularSifts(context,a){
			const data =await getregularSift(a)
			data.data.splice(2,data.data.length)
			context.commit('regularSift',data.data)
		},
		//查询定期理财c产品进阶精选优品展示 ps：所有
		async getregularSiftWinnows(constex,a){
			const data =await getregularSiftWinnow()
		
		constex.commit('regularSiftWinnow',data.data)
		},
		//定期理财详情展示
		async getregularDetails(context,a){
			const data =await getregularDetail(a)
		
			context.commit('regularDetail',data.data)
		},
		//查询定期理财产品详情展示折线图数据
		async getregularMinuteProducts(context,a){
			
			const data = await getregularMinuteProduct(a)
			console.log(a)
			console.log(data)
			context.commit('regularMinuteProduct',data.data)
		},
		//查询定期期理财产品持有列表
		async getregularHoldsProducts(context,a){
			const data =await getregularHoldsProduct()
			console.log(data)
			context.commit('holdsProduct',data.data)
		},
		//搜索
		async getAllProducts(context,a){
			const data =await getAllProduct(a)
			context.commit('funds',data.data.funds.searchHits)
			context.commit('golds',data.data.golds.searchHits)
			context.commit('regular',data.data.regular.searchHits)
			context.commit('sifts',data.data.sifts.searchHits)
			console.log(data.data.sifts.searchHits)
		},
		//活期理财产品持有列表
		async getholdsProducts(context, a) {
			const data = await getholdsProduct()
			context.commit('holdsProduct', data.data)
		},
		//黄金理财产品持有列表
		async getUserGoldProductList(context, a) {
			const data = await getUserGoldProductList()
			context.commit('holdsProduct', data.data)
		},
		//赎回
		async sellCurrents(context,a){
			console.log(a)
			const data = await sellCurrent(a)
			console.log(data)
		},
		//获取验证码
		async sendCodes(context,a){
			console.log(a,'2222')
			const data = await  sendCode(a)
			console.log(data)
		}
	},


})
